package org.onejava.db.transaction;

import java.sql.Connection;

/**
 * 事务实体类
 * @author frost
 *
 */
public class TransactionEntity {
	/**
	 * 事务分类:
	 * 1.(REQUIRED)如果一个事务存在，则支持当前事务，如果不存在，则创建新的事务
	 * 2.(SUPPORTS)如果一个事务存在，则支持当前事务，如果不存在，则非事务的方法运行
	 * 3.(NEW)总是要开启一个新的事务，如果事务存在，将该事务挂起
	 * 4.(NESTED)某一个事务存在，则运行在一个嵌套的事务中
	 */
	private int type;
	private Connection conn;
	private int count;
	private TransactionEntity subEntity;
	
	public TransactionEntity(int type,Connection conn,int count){
		this.type=type;
		this.conn=conn;
		this.count=count;
	}
	public int addCount(){
		return count++;
	}
	public int subCount(){
		return count--;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public Connection getConn() {
		return conn;
	}
	public void setConn(Connection conn) {
		this.conn = conn;
	}
	public int getCount() {
		return count;
	}
	public void setCount(int count) {
		this.count = count;
	}
	public TransactionEntity getSubEntity() {
		return subEntity;
	}
	public void setSubEntity(TransactionEntity subEntity) {
		this.subEntity = subEntity;
	}
}
